package com.xdq.quartz;

import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * @author: 徐东强
 * @date: 2018/9/28 下午10:17
 * @description:
 **/
@NoArgsConstructor
@Slf4j
public class NewJob implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        try {
            log.info("执行业务----job:" + context.getJobDetail()+"--trigger: "+context.getTrigger());
        } catch (Exception e){
            log.error("job execute fail ", e);
            JobExecutionException je = new JobExecutionException(e);
            je.refireImmediately();
            throw je;
        }
    }
}
